package com.sz.app.customer.api.logistics;

import com.sz.biz.app.web.BaseController;
import com.sz.biz.common.constants.CommCodes;
import com.sz.biz.logistics.constants.BaseConstants;
import com.sz.biz.logistics.constants.OrderConstants;
import com.sz.common.base.dto.ResultDto;
import com.sz.biz.logistics.ord.service.OrdOrderTrackingService;
import com.sz.biz.logistics.ord.dto.OrdOrderTrackingShowDto;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * Function: 物流信息controller
 * Author: yanhong.xiao.<br>
 * Date: 2017-06-05 15:13:00.
 */
@RestController
@RequestMapping("/api/v1/order/trackings")
@Api(description = " ", tags = "037-002、订单的物流信息")
public class OrdOrderTrackingController extends BaseController {

    @Autowired
    private OrdOrderTrackingService ordOrderTrackingService;

    /**
     * 根据订单号批量获取订单的物流信息,最多10个
     *
     * @param wayBillNos
     * @return
     */
    @ApiOperation(value = "批量查询订单的物流信息", notes = "根据指定订单编号集合删除数据<br>权限：", httpMethod = "POST")
    @RequestMapping(value = "/wayBillNos", method = {RequestMethod.POST})
    public ResultDto batchGetTracking(@RequestBody @ApiParam(value = "要查询的订单号集合", required = true) List<String> wayBillNos) {
        List<Integer> rankList = new ArrayList<>();
        rankList.add(OrderConstants.OrderTrackRank.TRACKING_CUSTOMER);
        Map<String, Map<String, List<OrdOrderTrackingShowDto>>> orderTrackingMap = ordOrderTrackingService.findByWaybillNo(rankList, wayBillNos);
        ResultDto result = new ResultDto();
        result.setData(orderTrackingMap);
        return result;
    }

}
